import {ElLoading} from "element-plus";

let loadingInstance = null;

// 显示 loading 动画
export const showLoading = (loadingText = '加载中...') => {
    loadingInstance = ElLoading.service({
        lock: true,
        text: loadingText,
        background: 'rgba(147,147,147,0.7)'
    });
};

// 隐藏 loading 动画
export const hideLoading = () => {
    if (loadingInstance) {
        loadingInstance.close();
        loadingInstance = null;
    }
};
